#Code BY ARi
import os,sys,time
import core
R = '\033[31m' # Red
N = '\033[1;37m' # White
G = '\033[32m' # Green
O = '\033[0;33m' # Orange
B = '\033[1;34m' #Blue
E = '\033[0m' # End
def clean():
    os.system("clear")

def explo():
    os.system('searchsploit exploits .txt')
    list = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"exploitdb/exploits"+G+"(open_file (ex:exploits/path/file.txt))"+N+"): ")
    print ""+G+""
    print('\nSelect "open" '+list)
    print'Command           Description'
    print'--------         ------------'
    print('open             open_file => '+list)
    print('back             back ')
    print('exit             exit PTF\n')
    pl = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"exploitdb/exploits"+N+"): ")
    if pl == "back":
         core.menu.exploit_db()
    elif pl =='open':
        time.sleep(3)
        print""+G+""
        os.system('figlet open && cat /usr/share/exploitdb/%s' % (list))
        print
        core.menu.exploit_db()
    elif pl == 'clear':
         clean()
         explo()
    elif pl =='exit':
         print
         print""+G+"Thanks for using PTF"
         print
         exit()
    else:
        print "Wrong Command => ", pl
        print ""+N+""+B+"["+R+"!"+B+"] "+N+"Please enter 'show options'"
        explo()

def shel():
    os.system('figlet shellcode')
    time.sleep(5)
    os.system('searchsploit shellcodes .txt')
    list = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"exploitdb/shellcode"+G+"(open_file (ex:shellcodes/path/file.txt))"+N+"): ")
    print ""+G+""
    print('\nSelect "open" '+list)
    print'Command           Description'
    print'--------         ------------'
    print('open             open_file => '+list)
    print('back             back ')
    print('exit             exit PTF\n')
    ope = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"exploitdb/shellcode"+N+"): ")
    if ope == "back":
         core.menu.exploit_db()
    elif ope =='open':
        time.sleep(3)
        print""+G+""
        os.system('figlet open && cat /usr/share/exploitdb/%s' % (list))
        print
        core.menu.exploit_db()
    elif ope == 'clear':
         clean()
         shel()
    elif ope =='exit':
         print
         print""+G+"Thanks for using PTF"
         print
         exit()
    else:
        print "Wrong Command => ", ope
        print ""+N+""+B+"["+R+"!"+B+"] "+N+"Please enter 'show options'"
        shel()
def searchsploit():
    list = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"searchsploit"+G+"(input search cve/vulnerability)"+N+"): ")
    time.sleep(6)
    os.system('searchsploit %s'% (list))
    list = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"searchsploit"+G+"(open_file (ex:/path/path/file))"+N+"): ")
    print ""+G+""
    print('\nSelect "open" '+list)
    print'Command           Description'
    print'--------         ------------'
    print('open             open_file => '+list)
    print('copy             copy file directory '+list)
    print('back             back ')
    print('exit             exit PTF\n')
    ope = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"searchsploit"+N+"): ")
    if ope == "back":
         core.menu.exploit_db()
    elif ope =='open':
        time.sleep(3)
        print""+G+""
        os.system('figlet open && cat /usr/share/exploitdb/%s' % (list))
        print
        core.menu.exploit_db()
    elif ope =='copy':
        dir = raw_input(""+N+"Pentest>> ("+B+"modules/exploitdb)("+R+"searchsploit"+G+"(Select Dir (/home/...))"+N+"): ")
        time.sleep(3)
        print""+G+""
        os.system('cp /usr/share/exploitdb/%s %s' % (list,dir))
        print
        print('copy success =>'+dir)
        core.menu.exploit_db()
    elif ope == 'clear':
         clean()
         shel()
    elif ope =='exit':
         print
         print""+G+"Thanks for using PTF"
         print
         exit()
    else:
        print "Wrong Command => ", ope
        print ""+N+""+B+"["+R+"!"+B+"] "+N+"Please enter 'show options'"
        shel()
